home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20041116-20060924
/
000361_fdc@columbia.edu_Tue Jun 20 10:42:52 2006.msg
< prev
next >
Wrap
Text File
|
2020-01-01
|
4KB
|
110 lines
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Assigning output from LINEOUT to a variable
Date: 20 Jun 2006 14:39:38 GMT
Organization: Columbia University
Lines: 93
Message-ID: <slrne9g25a.h41.fdc@sesame.cc.columbia.edu>
References: <1150811644.629253.47720@r2g2000cwb.googlegroups.com>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1150814378 11518 128.59.59.56 (20 Jun 2006 14:39:38 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 20 Jun 2006 14:39:38 GMT
User-Agent: slrn/0.9.8.0 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15618
On 2006-06-20, toastyboy@googlemail.com <toastyboy@googlemail.com> wrote:
From: Frank da Cruz <fdc@sesame.cc.columbia.edu>
To: toastyboy@googlemail.com
Subject: Re: Assigning output from LINEOUT to a variable
In-Reply-To: <1150811644.629253.47720@r2g2000cwb.googlegroups.com>
: I'm using kermit to control a quasar electronics 3108 serial module, at
: present I am calling the kermit script i have written from a bash shell
: script and it works ok, but it is inefficient.
:
: I'm hoping to write the whole thing inside a kermit script, however I'm
: stuck....
:
: I can read in a file and then assign the value contained in that file
: to a variable that works a treat! See below:
:
: OPEN READ /u01/status/OUT58
: READ \%a
: close read-file
:
: if ( == \%a 0 ) {
: LINEOUT F1
: INPUT 5 \"#\"
: } else {
: LINEOUT N1
: INPUT 5 \"#\"
: }
:
: As I say that works well, however I need to be able to do (say)
:
: LINEOUT I1
:
: which will give me the status of input line 1 and then take the output
: of this and if it is 1 then do something, if it is 0 then do something
: else.
:
: So I need something like:
:
: LINEOUT I1 > \%a
: INPUT 5 \"#\"
: if ( == \%a 0 ) {
: echo 1 > IN11
: } else {
: echo 0 > IN11
: }
:
: ...but I've just made up the syntax of the fist line "LINEOUT I1 >
: \%a" I need to know how to inject the output of this command to a
: variable.
:
First let's assume you're using the current version of C-Kermit, 8.0:
http://www.columbia.edu/kermit/ckermit.html
If not, you should pick it up. Then see:
http://www.columbia.edu/kermit/ckscripts.html
about how to construct a Kermit script that you can run directly from
the shell, as if it were a shell script. Remember to put in IF FAIL or
IF SUCCESS tests after critical commands after which you don't want the
script to keep going if they fail:
#!/usr/local/bin/kermit
.file := /u01/status/OUT58
open read \m(file)
if fail exit 1 "?\m(file): Open failed"
read \%a
if fail exit 1 "?\m(file): Read failed"
close read-file
if == \%a 0 lineout F1
else lineout N1
input 5 \"#\"
if fail exit 1 "?INPUT timed out"
Now the next part I'm not sure about. You want to send "I1" and then read
back the response into a variable. I can show you how to do that but first
you have to tell me how to parse the response. Plus I'm not sure what
you're trying to accomplish the with the ECHO commands.
Usually the pattern is, you do an OUTPUT to make the thing on the other
end send some results, and then you do an INPUT to read the results. Since
you don't know what the results will be, the thing your INPUT command is
looking for is a line terminator, or the next prompt, etc. Then if the
INPUT command succeeds, the \v(input) variable contains whatever was read
by the INPUT command (and, in fact, previous ones too, unless you gave a
CLEAR INPUT command before issuing the INPUT command)
Then you would use the Kermit's string processing functions such as
\findex(), \fsubstring(), etc, to extract the desired item from the the
\v(input) variable.
- Frank